﻿using PBO.Game.BattleClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace PBO.Util
{
    public static class StringHelper
    {
        public static int InRange(this int value, int min, int max)
        {
            int v = Math.Max(min, value);
            v = Math.Min(max, v);
            return v;
        }

        public static IEnumerable<T> GetLastLines<T>(this IEnumerable<T> array, int count)
        {
            int total = array.Count();
            int skip = Math.Max(0, total - count);
            return array.Skip(skip).Take(count);
        }

        public static string ShowPokemonInfo(Pokemon pokemon)
        {
            var text = new StringBuilder();
            text.AppendLine(pokemon.NickName);
            text.AppendLine(string.Format("LV : {0}", pokemon.LV));
            text.AppendLine(string.Format("HP : {0}/{1}", pokemon.HealthPower, pokemon.MaxHp));

            text.AppendLine("攻击 : " + pokemon.GetAttackValue());
            text.AppendLine("防御 : " + pokemon.GetDefenceValue());
            text.AppendLine("特攻 : " + pokemon.SpAttackValue);
            text.AppendLine("特防 : " + pokemon.SpDefenceValue);
            text.AppendLine("速度 : " + pokemon.SpeedValue);

            foreach (var move in pokemon.GetSelMoves())
            {
                text.AppendLine(" - " + move.Data.Name);
            }

            text.AppendLine("道具 : " + pokemon.GetItem().ToString());
            text.AppendLine("特性 : " + pokemon.GetSelTrait().ToString());

            return text.ToString();
        }
    }
}
